package com.zhanghe.mall.service.vo;

import com.zhanghe.mall.pojo.CommodityClassificationTree;
import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.List;

public class CommodityClassificationTreeVO extends BaseVO{

    public Long id;
    public String name;
    public String label;
    public List<CommodityClassificationTreeVO> children;

    public static List<CommodityClassificationTreeVO> transformList(List<CommodityClassificationTree> list){
        List<CommodityClassificationTreeVO> result = new ArrayList<CommodityClassificationTreeVO>();
        for( CommodityClassificationTree tree : list){
            CommodityClassificationTreeVO vo = new CommodityClassificationTreeVO();
            BeanUtils.copyProperties(tree.getDescendant(),vo);
            vo.setLabel(tree.getDescendant().getName());
            result.add(vo);
        }
        return result;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public List<CommodityClassificationTreeVO> getChildren() {
        return children;
    }

    public void setChildren(List<CommodityClassificationTreeVO> children) {
        this.children = children;
    }

    public String getLabel() {
        return label;
    }

    public void setLabel(String label) {
        this.label = label;
    }
}
